package com.lingying.caiwudailikehudaun.mapper.power;

import com.lingying.caiwudailikehudaun.domain.ceiWuDaiLiUserBean.CaiWuDaiLiUserBean;
import com.lingying.caiwudailikehudaun.domain.keHuDuanJueSeYeMian.KeHuDuanJueSeYeMian;
import com.lingying.caiwudailikehudaun.dto.PowerDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface PowerMapper {

//    /**
//     * 根据当前登录人的userId和jiGouId
//     * 查询到caiWuDaiLiUser表中的数据
//     * 根据角色加载不同的导航栏
//     *
//     * 桑满  20210427
//     * @param
//     * @param
//     * @return
//     */
//    @Select("select caiWuDaiLiKeHuYeMianUrl, caiWuDaiLiYeMianName, fId from caiWuDaiLiKeHuYeMian")
//    List<PowerDTO> selectKeHuUserRoleYeMian();

    /**
     * 根据当前用户id查询到caiWuDaiLiUser表中所有的公司名和做账申报id用于前端下拉回显
     * 桑满  20210428
     * @return
     */
    @Select("select zuoZhangShenBaoId, companyName, daiLiShangCid from waiBuRenYuan where phone=#{phone}")
    List<CaiWuDaiLiUserBean> queryCompanyName(String phone);

    /**
     * 根据当前登陆人信息查询到所属的角色id
     * 桑满20210730
     * @return
     */
    @Select("select jueSe from waiBuRenYuan where zuoZhangShenBaoId = #{zuoZhangShenBaoId} and phone = #{phone} and xianShiZhuangTai = ${1} and jiGouId = #{jiGouId}")
    Integer queryRoleYeMian(Integer waiBuRenYuanId, Integer zuoZhangShenBaoId, String phone, Integer jiGouId);

    /**
     * 查询当前机构下该外部人员角色所拥有的页面
     * 桑满20210730
     * @param jiGouId
     * @param jueSeId
     * @return
     */
    @Select("select js.keHuDuanYeMianLuJingId, js.keHuDuanJueSeId, ym.yeMianUrl, ym.yeMianName, ym.fId, " +
            "(select yeMianName from keHuDuanYeMianLuJing where keHuDuanYeMianLuJingId = ym.fId) fName " +
            "from keHuDuanJueSeYeMian js left join keHuDuanYeMianLuJing ym " +
            "on js.keHuDuanYeMianLuJingId = ym.keHuDuanYeMianLuJingId " +
            "where js.jiGouId = #{jiGouId} and js.keHuDuanJueSeId = #{jueSeId} and js.xianShiZhuangTai = ${1} ORDER BY paiXu asc")
    List<PowerDTO> queryJueSeYeMian(Integer jiGouId, Integer jueSeId);

//    /**
//     * 根据当前用户前端选中的下拉值拿到当前公司的做账申报id
//     * 桑满  20210428
//     * @param
//     * @return
//     */
//    @Select("select zuoZhangShenBaoId from ZuoZhangShenBao where companyName=#{companyName}")
//    ZuoZhangShenBaoBean queryCompanyId(String companyName);
}
